var jsonList = {};
//jsonList.state=4;
var page = 1;
var rows = 10;
var newid = getUrlParam("id")||'';
jsonList.sid = newid;
var bxlist = [];
//添加
$(function (){
	$(".btn3").click(function (){
		window.history.back(-1);
	})
})
 $(".xz").click(function(){
    $('.shouye').hide();
	$('.tab-box').show();
	 //$.FreeTags('tags');
	 $('.t_box').hide();
	 $(".sd_pipei").hide();
});
//修改
$(".xg").on('click',function(){
        var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid");
			}
		})
		if (numCount == 1) {
			//进行下一步
			$('.shouye').hide();
			$('.tab-box').show();
			$('.t_box').hide();
			$(".sd_pipei").hide();
			console.log(ids,898989);
			var json = {}
			var result = JSON.stringify(json);
			$.ajax({
			url: baseNews +"/api/data/article/info",
			data:{
				id: ids
			},
			success:function (res){
				//console.log(res,7878)
				if(res.code==0){
					var result=res.data;
					console.log(result);
					$(".wz_id").val(ids);
				 $(".wz_name1").val(result.title);//文章名称
				//var isTop = $(".arc_top").prop("checked");//是否置顶
				//var arcImg = $(".tu img").attr("fsrc")||"";//封面图
				//var arcid = $(".ztid_text").val();//专题id
				$(".ly_text").val(result.source);//来源
				var wz_text = $(".wz_text").val(result.url);//网址
				var zj_text = $(".zj_text").val(result.author);//作者
				//var mz_checkbox = $(".mz_checkbox").prop("checked");//免责声明
				$(".fbs_text").val(result.stime);//发布时间
				//$(".zq_se").val(result.sid);//专题id
				$(".zq_se option").each(function (index,key){
					if($(key).attr("value")==result.sid){
						$(key).attr("selected","selected")
					}

				})
				//$(".arc_pindao").val(result.id);//频道id
				
				//$(".arc_lb").val(result.type);//类别
				var chelb=result.type;
				$(".seC_list option").each(function (index,key){
					if($(key).attr("value")==chelb){
						$(key).attr("checked","checked")
					}

				})
				var imgArr=result.images;
					if(imgArr.length>0){
						var html="";
						$(imgArr).each(function (index,key){
							html+=`<div style="float:left;background:#f3f3f3;margin-right:30px;width: 160px;height: 160px;position: relative;">
							<a  class="label" >
								<img src="${key}"  class="img0" >
							</a>
						</div>`;
						
						})
						$(".show_tHimg").append(html);
					}
				// 默认的类别
				$(".seC_list option").each(function(index,key){
					if($(key).attr("value")==result.type){
						$(this).attr("selected","selected")
					}
				})
				//var scont = editor.txt.html();//文章内容
				$(".t_name").val(result.title);
				//$(".b_bianqian").attr("value",result.tags);
				//$.FreeTags('tags');
					var tags = "";
					for (var i = 0; i < result.tagArray.length; i++) {

						for (var j = 0; j < bxlist.length; j++) {
							if (result.tagArray[i] == bxlist[j].id) {
								tags = tags + bxlist[j].tag + ",";
							}
						}
						// if (bxlist[i] == cont) {
						// 	tags = tags + bxlist[i].id + ","
						// }
					}
					$(".add_biaoq").attr("value", tags);
					// $('#form-tags-4').tagsInput({
					// 	'autocomplete': {
					// 		source: zt_biao
					// 	}
					// });
				editor.txt.html(`${result.content}`);
					//$(".t_top").prop("checked");
					if(result.top==true){
						$(".arc_top").prop("checked",true);
					}
					if(result.statement==true){
						$(".mz_checkbox").prop("checked",true);
					}
					$(".t_jianjie").val(result.synopsis);
					if (result.cover!=""){
						$(".tu img").attr("src", result.cover);
						$(".tu img").attr("fsrc", result.cover);
					}

					
				}
			}
		})
			
		} else {
			//遮罩层提示
			zeroModal.alert("请选择一条数据进行修改");
			return false;

		}

    	
});
//获取默认列表
getList();
function getList() {
	var result = JSON.stringify(jsonList);
	$.ajax({
		url: baseNews + "/api/data/article/list?page=" + page + "&rows=" + rows,
		type: "post",
		headers: { 'Content-Type': 'application/json' },
		dataType: "json",
		data: result,
		success: function (res) {
			console.log(res, 666);
			if (res.code == 0) {
				var result = res.data;
				var list = result.list;
				console.log(list,9999)
				var html = "";
				$("#page").paging({
					pageNo: page,
					totalPage: result.totalpage,
					totalSize: result.totals,
					callback: function (num) {
						page = num;
						getList();
					}
				})
				$(".arc_list").empty();
				$(list).each(function (index, key) {
					var state = key.state;//文章的状态
					var state1 = key.sstate//专题的状态
					var newState = "";//文章的
					var newState1="";//专题的
					if (state == 0) {
						newState = "新建";
					}
					if (state == 1) {
						newState = "已修改";
					}
					if (state == 2) {
						newState = "待审核";
					}
					if (state == 3) {
						newState = "待发布";
					}
					if (state == 4) {
						newState = "已发布";
					}
					if (state == 10) {
						newState = "新匹配";
					}
					if (state == -10) {
						newState = "已忽略";
					}
					if (state == -1) {
						newState = "审核失败";
					}
					if (state == -2) {
						newState = "撤销发布";
					}
					//
					if (state1 == 1) {
						newState1 = "待审核";
					}
					if (state1 == 2) {
						newState1 = "待发布";
					}
					if (state1 == 3) {
						newState1 = "已发布";
					}
					if (state1 == 10) {
						newState1 = "有更新";
					}
					if (state1 == -1) {
						newState = "审核失败";
					}
					if (state1 ==-2) {
						newState1 = "撤销发布";
					}
					html += `<tr >
							<td >
								<input type="checkbox" oid="${key.id}" class="arc_isc"/>
							</td>
							<td >${key.id}</td>
							<td >${key.title}</td>
							<td >${newState}</td>
							<td >${key.sid}</td>
							<td >${key.stitle == null ? '' : key.stitle}</td>
							<td >${newState1}</td>
							<td >${key.cname == null ? '' : key.cname}</td>
							<td >${key.type?key.type:''}</td>
							<td >${key.top == true ? "是" : "否"}</td>
							<td >${key.recommend == true ? "是" : "否"}</td>
							<td >${key.diy == true ? "是" : "否"}</td>
							<td >${key.statement == true ? "有" : "无"}</td>
							<td >${key.click?key.click:''}</td>
							<td >${key.collect?key.collect:''}</td>
							<td >${key.pass?key.pass:''}</td>
							<td >${key.comment?key.comment:""}</td>
							<td >${key.hot?key.hot:""}</td>
							<td >${key.username?key.username:""}</td>
							<td >${key.createtime?key.createtime:""}</td>
							<td >${key.updatetime?key.updatetime:''}</td>
							<td >${key.atime?key.atime:""}</td>
							<td >${key.rtime?key.rtime:""}</td>
							<td >${key.source?key.source:''}</td>
							<td >${key.author?key.author:""}</td>
							<td >${key.stime?key.stime:''}</td>
							<td >xxx</td>
						</tr>`;
				})
				$(".arc_list").append(html);
			}
		}

	})
	//分页

}
$(function (){
	//图片上传预览
	$('.file').on('change', function (e) {
		var e = e || event;
		var reader = new FileReader();
		console.log(reader)
		reader.readAsDataURL($('.file')[0].files[0]);//发起异步请
		//上传图片1
		sendImg('.tu img', $('.file')[0].files[0])
		reader.onload = function () {
			var src = this.result
			$('.tu img').attr('src', src)
		}
	})
	//获取专题id
	$.ajax({
		url: baseNews + "/api/data/article/special/select",
		success: function (res) {
			console.log(res);
			if (res.code == 0) {
				var obj = $(".zq_se");
				var obj1 = $(".atc_ztid");
				$(res.data).each(function (index, key) {
					obj.append("<option value='" + key.id + "'>" + key.value + "</option>");
					obj1.append("<option value='" + key.id + "'>" + key.value + "</option>");
				})
			}
		}
	})
	//获取频道列表
	$.ajax({
		url: baseNews + "/api/data/special/channel/select",
		success: function (res) {
			console.log(res);
			if (res.code == 0) {
				var obj = $(".arc_pindao");
				var obj1 = $(".arc_pd");
				$(res.data).each(function (index, key) {
					obj.append("<option value='" + key.id + "'>" + key.value + "</option>");
					obj1.append("<option value='" + key.id + "'>" + key.value + "</option>");
				})
			}
		}
	})
	//文章删除
	$('.arc_sc').click(function () {
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要删除该文章吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/del?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('删除文章失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章删除');

		}
	})
	//文章置顶
	$(".arc_zd").click(function () {
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要置顶该文章吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/top/true?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('置顶文章失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章置顶');

		}
		//return false;
	})
	//文章取消置顶
	$(".arc_zdqx").click(function () {
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要取消置顶该文章吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/top/false?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('取消文章置顶失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章取消置顶');

		}
		//return false;
	})
	//文章推荐
	$(".arc_tj").click(function () {
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要推荐该文章吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/recommend/true?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('推荐文章失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章推荐');

		}
		//return false;
	})
	//文章取消推荐
	$(".arc_qxtj").click(function () {
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要取消推荐该文章吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/recommend/false?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('取消推荐文章失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章取消推荐');

		}
		//return false;
	})
	//添加免责声明
	$(".arc_addm").click(function (){
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要添加免责声明吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/statement/true?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('添加免责声明失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章添加免责声明');

		}
	})
	//删除免责声明
	//添加免责声明
	$(".arc_addmqx").click(function () {
		var numCount = 0;
		var ids = '';
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		console.log(numCount, 555);
		if (numCount >= 1) {
			//进行下一步
			var json = {}
			var result = JSON.stringify(json);
			zeroModal.confirm("确定要删除免责声明吗？", function () {
				//置顶确认请求数据
				$.ajax({
					url: baseNews + "/api/data/article/statement/false?ids=" + ids,
					type: "post",
					headers: { 'Content-Type': 'application/json' },
					dataType: "json",
					data: result,
					success: function (res) {
						if (res.code == 0) {
							location.reload();
						} else {
							zeroModal.alert('删除免责声明失败');
						}
					}
				})
			});
		} else {
			//遮罩层提示
			zeroModal.alert('请选择至少一条文章删除免责声明');

		}
	})
	//搜索
	$(".arc_sele").change(function (){
		jsonList.state = $(this).val();
	})
	$(".atc_ztid").change(function (){
		jsonList.sid =$(this).val();
	})
	$(".arc_pd").change(function () {
		jsonList.cid  = $(this).val();
	})
	$(".arc_sou").click(function (){
		var arc_name = $(".arc_name").val();
		var arc_sele = $(".arc_sele").val();//文章状态
		console.log(arc_sele,333)
		if (arc_name!= "") {
			jsonList.title = arc_name
		}
		if (arc_sele==0){
		}else{
			jsonList.state = arc_sele;
		}
		//var atc_ztid = $(".atc_ztid").val()//专题
		page = 1;
		getList();
	})

})
// 图片上传的。。
function sendImg(obj, msrc) {
	var formData = new FormData();
	formData.append('file', msrc);
	$.ajax({
		url: baseNews + '/oss/upload/img',
		data: formData,
		type: "post",
		cache: false,
		processData: false,
		contentType: false,
		success: function (res) {
			console.log(res);
			if (res.code == 0) {
				$(obj).attr("fsrc", res.data);
			} else {
				alert("上传失败");
				return false;
			}
		}

	})
}
// $(".btn_title_chuang").click(function (){
// 	var arctitle = $(".wz_name1").val()||"";//文章名称
// 	var isTop = $(".arc_top").prop("checked");//是否置顶
// 	var arcImg = $(".tu img").attr("fsrc")||"";//封面图
// 	//var arcid = $(".ztid_text").val();//专题id
// 	var ly_text = $(".ly_text").val();//来源
// 	var wz_text = $(".wz_text").val();//网址
// 	var zj_text = $(".zj_text").val();//作者
// 	var mz_checkbox = $(".mz_checkbox").prop("checked");//免责声明
// 	var fbs_text = $(".fbs_text").val();//发布时间
// 	var zq_se = $(".zq_se").val();//专题id
// 	var arc_pindao = $(".arc_pindao").val();//频道id
// 	var arc_lb = $(".arc_lb").val();//类别
// 	var scont = editor.txt.html();//文章内容
// 	var tags = "";
// 	$(".tag").each(function (index, key) {
// 		var cont = $(this).find("span").html();
// 		for (var i = 0; i < bxlist.length; i++) {
// 			if (bxlist[i].tag == cont) {
// 				tags = tags + bxlist[i].id + ","
// 			}
// 		}

// 	})
// 	tags = tags.substring(0, tags.length - 1);
// 	if (editor.txt.text()==""){
// 		zeroModal.alert('请填写文章内容');
// 		return false;
// 	}
// 	if (arcImg==""){
// 		zeroModal.alert('请选择封面图片');
// 		return false;
// 	}
// 	if (arctitle==""){
// 		zeroModal.alert('请输入标题');
// 		return false;
// 	}
// 	if (arc_lb==null){
// 		zeroModal.alert('请输入类别');
// 		return false;
// 	}
// 	var json = {
// 		"author": zj_text,
// 		"content":scont,
// 		"cover": arcImg,
// 		"id": Number(arc_pindao),
// 		"sid":Number(zq_se),
// 		"source": ly_text,
// 		"statement": mz_checkbox,
// 		"stime": fbs_text+":00",
// 		"tags": tags,
// 		"title": arctitle,
// 		"top": isTop,
// 		"type": arc_lb,
// 		"url": wz_text
// 	}
// 	console.log(json,9999)
// 	var result = JSON.stringify(json);
// 	$.ajax({
// 		url: baseNews +"/api/data/article/update",
// 		type: "post",
// 		headers: { 'Content-Type': 'application/json'},
// 		dataType: "json",
// 		data: result,
// 		success:function (res){
// 			console.log(res,666)
// 			if(res.code==0){
// 				//location.reload();
// 				console.log(res,555);
// 			}else{

// 				zeroModal.alert('添加失败');

// 			}
// 		}
// 	})
// })
$(function (){
	//手动匹配
	$(".sd_button").on('click',function (){
		var sd_pipei = $(".val_input").val();//更新时间
		var str ='';
		console.log(sd_pipei)
		if (sd_pipei == "") {
		}else{
			str ='?start=';
			sd_pipei+=":00";
			str += sd_pipei;
		}
		$.ajax({
			url: baseNews + "/api/data/special/match/" + newid + str,
			success:function (res){
				if(res.code==0){
					location.reload();
				}else{
					zeroModal.alert('专题手动更新失败');
				}
			}
		})
	})
})
$(function () {
	//获取专题的标签详情
	$.ajax({
		url: baseNews + "/api/data/article/tag/list",
		success: function (res) {
			console.log(res, 666);
			var result = res.data;
			var arr = [];
			bxlist = result;
			arr = result.map(function (key, index) {
				return `${key.tag}`;
			})
			zt_biao = arr;


		}
	})
})
$(function () {
	//修改详情
	$(".btn_title_chuang").on("click", function () {
		var arctitle = $(".wz_name1").val() || "";//文章名称
		var isTop = $(".arc_top").prop("checked");//是否置顶
		var arcImg = $(".tu img").attr("fsrc") || "";//封面图
		//var arcid = $(".ztid_text").val();//专题id
		var ly_text = $(".ly_text").val();//来源
		var wz_text = $(".wz_text").val();//网址
		var zj_text = $(".zj_text").val();//作者
		var mz_checkbox = $(".mz_checkbox").prop("checked");//免责声明
		var fbs_text = $(".fbs_text").val();//发布时间
		var zq_se = $(".zq_se").val();//专题id
		//var arc_pindao = $(".arc_pindao").val();//频道id
		var arc_lb = $(".seC_list").val();//类别
		var scont = editor.txt.html();//文章内容
		var tags = "";
		// $(".input_box a").each(function (index, key) {
		// 	tags = tags + $(this).find("span").html() + ',';
		// })
		$(".tag").each(function (index, key) {
			var cont = $(this).find("span").html();
			for (var i = 0; i < bxlist.length; i++) {
				if (bxlist[i].tag == cont) {
					tags = tags + bxlist[i].id + ","
				}
			}

		})
		tags = tags.substring(0, tags.length - 1);
		if (editor.txt.text() == "") {
			zeroModal.alert('请填写文章内容');
			return false;
		}
		if (arcImg == "") {
			zeroModal.alert('请选择封面图片');
			return false;
		}
		if (arctitle == "") {
			zeroModal.alert('请输入标题');
			return false;
		}
		if (arc_lb == null) {
			zeroModal.alert('请输入类别');
			return false;
		}
		if(fbs_text==""){
			fbs_text="";
		}else{
			fbs_text=fbs_text+":00";
		}
		var json = {
			"author": zj_text,
			"content": scont,
			"cover": arcImg,
			"id": $(".wz_id").val(),
			"sid": zq_se,
			"source": ly_text,
			"statement": mz_checkbox,
			"stime": fbs_text,
			"tags": tags,
			"title": arctitle,
			"top": isTop,
			"type": arc_lb,
			"url": wz_text
		}
		console.log(json, 9999)
		var result = JSON.stringify(json);
		zeroModal.loading(5);
		$.ajax({
			url: baseNews + "/api/data/article/update",
			type: "post",
			headers: { 'Content-Type': 'application/json' },
			dataType: "json",
			data: result,
			success: function (res) {
				console.log(res, 666)
				if (res.code == 0) {
					location.reload();
				} else {

					zeroModal.alert('添加失败');

				}
			}
		})
	})
})
$(function () {
	//获取专题的标签详情
	var json = {}
	var result = JSON.stringify(json);
	$.ajax({
		url: baseNews + "/api/data/special/keywords/" + newid,
		type: "post",
		headers: { 'Content-Type': 'application/json' },
		dataType: "json",
		data: result,
		success: function (res) {
			if (res.code == 0) {
				$(".input_texta").val(res.data);
			} else {

			}
		}
	})
	//保存关键字
	$(".save_key").on('click', function () {
		// var json = {}
		// var result = JSON.stringify(json);
		// var tags='';
		// $(".tag").each(function (index, key) {
		//     var cont = $(this).find("span").html();
		//     for (var i = 0; i < bxlist.length; i++) {
		//         if (bxlist[i].tag == cont) {
		//             tags = tags + bxlist[i].id + ","
		//         }
		//     }

		// })
		// tags = tags.substring(0, tags.length - 1);
		// if(tags==""){
		//     zeroModal.alert("请输入关键字");
		//     return  false;
		// }
		//置顶确认请求数据
		var result = JSON.parse($(".input_texta").val());
        var str = JSON.stringify(result);
        var json={
            keywords:str,
            sid: newid
        }
        var result1 = JSON.stringify(json);
        console.log(result1)
        $.ajax({
            url: baseNews + "/api/data/special/update/keywords?",
            type: "post",
            headers: { 'Content-Type': 'application/json' },
            dataType: "json",
            data:result1,
            success: function (res) {
                console.log(res,808080)
                if (res.code == 0) {
                    location.reload();
                } else {
                    zeroModal.alert(res.message);
                }
            }
        })
	})
})
$(function (){
	//录入
   $(".luru").on('click',function (){
	   var numCount = 0;
	   var ids = '';
	   $(".arc_isc").each(function (index, key) {
		   if ($(this).prop("checked") == true) {
			   numCount++;
			   ids = ids + $(this).attr("oid") + ',';
		   }
	   })
	   console.log(numCount, 555);
	   ids = ids.substring(0, ids.length - 1);
	   if (numCount >= 1) {
		   //进行下一步
		   var json = {}
		   var result = JSON.stringify(json);
		   zeroModal.confirm("确定要录入该文章吗？", function () {
			   //置顶确认请求数据
			   $.ajax({
				   url: baseNews + "/api/data/update/special/input/true?sid=" + newid+"&ids=" + ids,
				   type: "post",
				   headers: { 'Content-Type': 'application/json' },
				   dataType: "json",
				   data: result,
				   success: function (res) {
					   if (res.code == 0) {
						   location.reload();
					   } else {
						   zeroModal.alert('录入失败');
					   }
				   }
			   })
		   });
	   } else {
		   //遮罩层提示
		   zeroModal.alert('请选择至少一篇文章');

	   }
   })
   //文章忽略
   $(".hulv").on('click', function () {
	   var numCount = 0;
	   var ids = '';
	   $(".arc_isc").each(function (index, key) {
		   if ($(this).prop("checked") == true) {
			   numCount++;
			   ids = ids + $(this).attr("oid") + ',';
		   }
	   })
	   console.log(numCount, 555);
	   ids = ids.substring(0, ids.length - 1);
	   if (numCount >= 1) {
		   //进行下一步
		   var json = {}
		   var result = JSON.stringify(json);
		   zeroModal.confirm("确定要录入该文章吗？", function () {
			   //置顶确认请求数据
			   $.ajax({
				   url: baseNews + "/api/data/update/special/input/false?sid=" + newid + "&ids=" + ids,
				   type: "post",
				   headers: { 'Content-Type': 'application/json' },
				   dataType: "json",
				   data: result,
				   success: function (res) {
					   if (res.code == 0) {
						   location.reload();
					   } else {
						   zeroModal.alert('忽略失败');
					   }
				   }
			   })
		   });
	   } else {
		   //遮罩层提示
		   zeroModal.alert('请选择至少一篇文章');

	   }
   })
});

$(function (){
	$.ajax({
		url:baseNews+"/api/data/tag/article/list?page=1&rows=999",
		success:function (res){
			console.log(res.data.list,888888);
			var result=res.data.list;
			var arr = result.map(function (key, index) {
				return `${key.tag}`;
			})
			console.log(arr,890)
			$('#form-tags-5').tagsInput({
				'autocomplete': {
					source: arr
				}
			});
		}
	})
	//取消
	$(".add_nqx").on('click',function (){
		location.reload();
		
	})
	//添加
	$(".add_newbx").on("click",function (){
		var ids="";
		var tags="";
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				ids = ids + $(this).attr("oid") + '';
			}
		})
		$(".tag").each(function (index, key) {
			var cont = $(this).find("span").html();
			for (var i = 0; i < bxlist.length; i++) {
				if (bxlist[i].tag == cont) {
					tags = tags + bxlist[i].id;
				}
			}
	
		})
		if(tags==""){
			zeroModal.alert('请添加标签');
			return false;
		}
		$.ajax({
			url:baseNews+"/api/data/special/update/tags?sid="+ids+"&tags="+tags,
			type: "post",		
			data:{
				
			},
			success:function (res){
				console.log(res);
				if(res.code==0){
					location.reload();
				}else{
					zeroModal.alert(res.message);
				}
			}
		})
	})
	$(".addt_bx").on("click",function (){
		$(".input_texta").css("z-index","-1")
		var numCount = 0;
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				
			}
		})
		if(numCount==1){
			$(".add_biaoqian").show();
		}else{
			zeroModal.alert('请选择一篇文章添加标签');
		}
		
	})
	$(".hvsy").on('click',function(){
        zeroModal.confirm("确定要忽略录入所有吗？", function () {
            $.ajax({
                url:baseNews+"/api/data/update/special/ignore/"+newid,
                success:function (res){
                    if (res.code == 0) {
                        location.reload();
                    } else {
                        zeroModal.alert(res.message);
                    }
                }
            })
        })
	})
	//获取文章默认类别
	$.ajax({
		url:baseNews+"/api/data/article/types",
		success:function (res){
			console.log(res.data,555);
			var html="";
			$(res.data).each(function (index,key){
				html+=`<li oliName="${key.value}" oliId="${key.id}">${key.value}</li>`;
			})
			$(".selectUl").append(html);
			$(".selectBox .imitationSelect").on("click",function(){
				$(this).parent().next().toggle();//ul弹窗展开
				$(this).next().toggleClass("fa-caret-up")//点击input选择适合，小图标动态切换
				if (event.stopPropagation) {   
					// 针对 Mozilla 和 Opera   
					event.stopPropagation();   
				}else if (window.event) {   
					// 针对 IE   
					window.event.cancelBubble = true;   
				}   /*阻止事件传播，事件从点击的元素出发，向外（window）传播，
					如果不写个阻止事件，会导致下面的document点击函数一起执行，导致显示失败*/
					
			});
			$(".selectUl li").click(function(event){
				$(this).addClass("actived_li").siblings().removeClass("actived_li");//点击当前的添加。actived_li这个类；其他的移除这个类名
				var oliName = $(this).attr("oliName");//定义一个name属性，获取点击的元素属性赋值到当前，方便动态化传值
				var oliId = $(this).attr("oliId");//定义一个id属性，获取点击的元素属性赋值到当前，方便动态化传值
				$(this).parent().prev().children().val(oliName); //把当前点击的name赋值到显示的input的val里面
				$(this).parent().prev().children().attr("oliName",oliName);//把当前点击的oliName赋值到显示的input的oliName里面
				$(this).parent().prev().children().attr("oliId",oliId);//把当前点击的oliId赋值到显示的input的oliId里面
			});
			$(document).click(function(event){
				$(".inputCase .fa").removeClass("fa-caret-up").addClass("fa-caret-down")//当点隐藏ul弹窗时候，把小图标恢复原状
				$(".selectUl").hide();//当点击空白处，隐藏ul弹窗
			});
		}
	})

	//添加类别
	$(".addt_Nleb").on('click',function (){
		$(".input_texta").css("z-index","-1")
		var numCount = 0;
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				numCount++;
				
			}
		})
		if(numCount>0){
			$(".choise_bq").show();
		}else{
			zeroModal.alert('请选择一篇文章添加类别');
		}

	})
	$(".add_nlb").on('click',function (){
		var ids="";
		var tags="";
		$(".arc_isc").each(function (index, key) {
			if ($(this).prop("checked") == true) {
				ids = ids + $(this).attr("oid") + ',';
			}
		})
		if($(".imitationSelect").attr("oliid")!=undefined){
			tags=$(".imitationSelect").attr("oliid");
			//alert(tags)
		}else{
			zeroModal.alert("请选择类别");
			return false;
		}
		ids = ids.substring(0, ids.length - 1);


		$.ajax({
			url:baseNews+"/api/data/update/special/article/type?ids="+ids+"&type="+tags,
			type: "post",		
			data:{	
			},
			success:function (res){
				console.log(res);
				if(res.code==0){
					location.reload();
				}else{
					zeroModal.alert(res.message);
				}
			}
		})
	})
})
//修改默认类别

$(function (){
	$.ajax({
		url:baseNews+"/api/data/article/types",
		success:function (res){
			console.log(res.data,555);
			var html="";
			$(res.data).each(function (index,key){
				html+=`<option value="${key.id}">${key.value}</option>`;
			})
			$(".seC_list").append(html);
		}
	})
})